<style>
  .labels {
    width: 40px;
    float: left;
  }
</style>

<%= javascript_include_tag "jquery.js","ajaxupload.js" %>

<script>
$(document).ready(function(){
		var upload_file = new AjaxUpload('#upfile', {
      action: '/articles/a_upload_fi',
      autoSubmit: false,
			name: 'upload_file',
      onComplete : function(file,response){
        $("#uploaded_files").append(response);
			}	
    });		
    $("#add_file").click(function(){
      upload_file.submit();
    })
		
});
</script>

<% form_tag :action => "create" do %>

  <p>
  <label class="labels" for="article_title">标题:</label>
      <%= text_field :article,:title %>
  </p>
  <p>
      <label class="labels" for="article_permalink">URL&nbsp;:</label>
      <%= text_field :article,:permalink %>
  </p>

  <p> 
    <textarea name="content" id="mytxtarea" class="ed" cols="100" rows="20"></textarea>
  </p>
	<p>
		<select name="category">
			<% @categories.each do |category| %>
					<option value="<%= category.id %>"><%= category.name %></option>
			<% end %>
		</select>
    </p>
    <p>
<% Category.all.each do |e| %>
    <input type="checkbox" name="categories[]" value="<%= e.id %>"  /><%= e.name %>
<% end %>
    </p>

  <p>
    <%= submit_tag '发布' %>
  </p>
<% end %>

<div id="uploaded_files"></div>

<form action="#" method="post" id="upfile_form">
    <dl>
      <dt><label for="fileupload">文件:</label></dt>
      <dd>
          <input type="file" class="inputbox autowidth" value="" maxlength="262144" id="upfile" name="fileupload"/> 
          <input type="button"  class="button2" value="上传附件" name="add_file" id="add_file"/>
      </dd>
    </dl>
    <dl>
      <dt><label for="filecomment">描述:</label></dt>
      <dd><textarea class="inputbox autowidth" cols="40" rows="1" id="filecomment" name="filecomment"></textarea></dd>
    </dl>
 </form>

